home *** CD-ROM | disk | FTP | other *** search
- //=====================================================================
- //
- // exedef.h
- //
- // structures describing the format of executable files.
- //
- // Copyright (c) 1994, Kevin Morgan, All rights reserved.
- //
- //=====================================================================
- #ifndef __EXEDEF_H__
- #define __EXEDEF_H__
-
- //=====================================================================
- //
- // HEADER is the header from a normal executable code file
- // (also present before the "NE" new executable header).
- //
- //=====================================================================
- struct HEADER {
- char signature[2];
- WORD lastpagebytes; /* number of bytes in last page of .exe */
- WORD numpages; /* number of pages in the executable */
- WORD numreloc; /* number of relocation entries */
- WORD headersize; /* header size in paragraphs */
- WORD minalloc; /* minimum paragraphs in addition to exe size */
- WORD maxalloc; /* maximum paragraphs */
- WORD initialss; /* relative to start of exe */
- WORD initialsp;
- WORD checksum; /* ones complement of sum of all words in executable */
- WORD initialip; /* relative to start of exe */
- WORD initialcs;
- WORD relocoffs; /* offset within header of relocation table */
- WORD overlaynum; /* overlay number 0000h = main program */
- WORD junk_14, junk_15;
- WORD morejunk[16];
- };
-
- //=====================================================================
- //
- // NEHEADER is the header from a "NE" new executable code file
- //
- //=====================================================================
- struct NEHEADER {
- char signature[2]; // "NE"
- BYTE linkMajor, linkMinor;
- WORD entryOffset; // offset to entry table
- WORD entryLength; // length of entry table in bytes
- DWORD crc; // file load CRC (0 in Borland's TPW
- BYTE programFlags;
- BYTE applicationFlags;
- WORD dataSegmentIndex;
- WORD initialHeapSize;
- WORD initialStackSize;
- WORD initialIP;
- WORD initialCS;
- WORD initialSP;
- WORD initialSS;
- WORD segmentCount;
- WORD moduleReferenceCount;
- WORD nonResNameTableLength;
- WORD segmentTableOffset;
- WORD resourceTableOffset;
- WORD nameTableOffset;
- WORD moduleRefTableOffset;
- WORD importNameTableOffset;
- DWORD nonResNameTableOffset;
- WORD movableEntryPointCount;
- BYTE fileAlignmentShift;
- BYTE junk1, junk2, junk3;
- BYTE osType;
- BYTE otherExeFlags;
- WORD thunkOffset;
- WORD codeSwapSize;
- BYTE winMinor, winMajor;
- };
-
- //=====================================================================
- //
- // SegmentTable is a segment table entry from a "NE" (new executable)
- // file.
- //
- //=====================================================================
-
- struct SegmentTable {
- WORD offsetToSegment; // relative to beginning of file, shifted by fileAlignmentShift
- WORD length; // length of data in file
- WORD attributes; //
- WORD allocatedSize; // size of segment to allocate
- };
-
-
- //=====================================================================
- //
- // These structures describe the Debug information found in
- // Borland Executables. This is specific to Borland.
- //
- // For more detail about these and how to use them,
- // see the Borland's Open Architecture Handbook
- //
- //=====================================================================
- #define DEBUG_MAGIC 0x52fb
-
- struct DebugHeader {
- WORD magicNumber; // should be 0x52fb
- WORD versionId;
- DWORD names;
- WORD namesCount;
- WORD typesCount;
- WORD membersCount;
- WORD symbolsCount;
- WORD globalsCount;
- WORD modulesCount;
- WORD localsCount;
- WORD scopesCount;
- WORD linesCount;
- WORD sourceCount;
- WORD segmentCount;
- WORD correlationCount;
- DWORD imageSize;
- DWORD debuggerHook;
- BYTE programFlags;
- WORD unused1;
- WORD dataCount;
- BYTE unused2;
- WORD extensionSize;
- };
-
- struct DebugExtHeader {
- WORD classEntries;
- WORD parentEntries;
- WORD globalClasses;
- WORD overloadEntries;
- WORD scopeClassEntries;
- WORD moduleClassEntries;
- WORD coverageOffsetCount;
- DWORD namePoolOffset;
- WORD browserEntries;
- WORD optSymbolEntries;
- WORD debugFlags;
- char unused[8];
- };
-
- struct DebugSymbol {
- WORD symbolName;
- WORD symbolType;
- WORD symbolOffset;
- WORD symbolSegment;
- WORD symbolClass : 3;
- WORD hasValidBP :1;
- WORD returnAddressWordOffset : 3;
- };
-
- struct near DebugModule {
- WORD moduleName;
- BYTE language;
- WORD memoryModel:3;
- WORD underbarsOn:1;
- WORD symbolsIndex;
- WORD symbolsCount;
- WORD sourceFilesIndex;
- WORD sourceFilesCount;
- WORD correlationIndex;
- WORD correlationCount;
- };
-
- struct near DebugSourceFile {
- WORD sourceFileName;
- DWORD timeStamp;
- };
-
- struct DebugLineNumber {
- WORD lineNumberValue;
- WORD lineNumberOffset;
- };
-
- struct near DebugScope {
- WORD autosIndex;
- WORD autosCount;
- WORD parentScope;
- WORD functionSymbol;
- WORD scopeOffset;
- WORD scopeLength;
- };
-
- struct near DebugSegment {
- WORD modIndex;
- WORD codeSegment;
- WORD codeOffset;
- WORD codeLength;
- WORD scopesOffset;
- WORD scopesLength;
- WORD correlationIndex;
- WORD correlationCount;
- };
-
- struct DebugCorrelation {
- WORD segmentIndex;
- WORD fileIndex;
- WORD linesIndex;
- WORD linesCount;
- };
-
- #endif